<template>
  <view class="container">
    <image class="background-image" src="/static/bk3.jpg" mode="aspectFill" />
    <view class="profile-header">
      <image class="avatar" src="/static/bk3.jpg" />
      <text class="username">{{ userInfo.nickname }}</text>
    </view>
    <view class="profile-info" v-if="!isEditing">
      <view class="info-item">
        <text class="info-label">昵称</text>
        <text class="info-value">{{ userInfo.nickname }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">性别</text>
        <text class="info-value">{{ userInfo.gender }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">邮箱</text>
        <text class="info-value">{{ userInfo.email }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">手机</text>
        <text class="info-value">{{ userInfo.phone }}</text>
      </view>
      <view class="button-group">
        <button class="edit-button" @click="isEditing = true">编辑信息</button>
        <button class="logout-button" @click="logout">退出登录</button>
      </view>
    </view>
    <view class="profile-edit" v-else>
      <view class="edit-item">
        <text class="edit-label">昵称</text>
        <input class="edit-input" v-model="userInfo.nickname" />
      </view>
      <view class="edit-item">
        <text class="edit-label">性别</text>
        <input class="edit-input" v-model="userInfo.gender" />
      </view>
      <view class="edit-item">
        <text class="edit-label">邮箱</text>
        <input class="edit-input" v-model="userInfo.email" />
      </view>
      <view class="edit-item">
        <text class="edit-label">手机</text>
        <input class="edit-input" v-model="userInfo.phone" />
      </view>
      <view class="button-group">
        <button class="save-button" @click="saveProfile">保存</button>
        <button class="cancel-button" @click="isEditing = false">取消</button>
      </view>
    </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      isEditing: false,
      userInfo: {
        nickname: '茶花女',
        gender: '女',
        email: 'zhangsan@example.com',
        phone: '13549180721'
      }
    };
  },
  methods: {
    logout() {
      // 退出登录逻辑
      uni.showToast({
        title: '退出登录',
        icon: 'none'
      });
    },
    saveProfile() {
      // 保存个人信息逻辑
      this.isEditing = false;
      uni.showToast({
        title: '信息已保存',
        icon: 'none'
      });
    }
  }
};
</script>
<style>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-color: #f5f7fa;
  height: 100vh;
  position: relative;
  overflow: hidden;
  font-family: 'Arial', sans-serif;
}

.background-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  filter: blur(2px);
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
  margin-top: 20px;
  z-index: 1;
  animation: fadeInUp 1s ease-in-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin-bottom: 10px;
  border: 4px solid #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.username {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 5px 10px;
  border-radius: 5px;
}

.profile-info, .profile-edit {
  width: 100%;
  max-width: 400px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 30px;
  z-index: 1;
  animation: fadeInUp 1s ease-in-out;
}

.info-item, .edit-item {
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
  font-size: 16px;
}

.info-item:last-child, .edit-item:last-child {
  border-bottom: none;
}

.info-label, .edit-label {
  color: #333;
}

.info-value {
  color: #666;
}

.edit-input {
  color: #666;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 5px;
  width: 60%;
  font-size: 16px;
}

.button-group {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.edit-button, .save-button, .cancel-button, .logout-button {
  flex: 1;
  height: 40px;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s;
  margin: 0 5px;
}

.edit-button:hover, .save-button:hover {
  background-color: #0056b3;
}

.cancel-button {
  background-color: #ff3b30;
}

.cancel-button:hover {
  background-color: #e03126;
}

.logout-button {
  background-color: #ff3b30;
}

.logout-button:hover {
  background-color: #e03126;
}
</style>